#define _CRT_SECURE_NO_WARNINGS 1
#include<iostream>
#include<vector>
using namespace std;
int main()
{
	int n;	cin >> n;
	vector<int>nums;
	vector<int>sum;
	for (int i = 0; i < n; i++) {
		int x;	cin >> x;
		nums.push_back(x);
		if (sum.size() == 0)	sum.push_back(x);
		else   sum.push_back(sum[i - 1] + x);
	}
	int m;	cin >> m;
	for (int i = 0; i < m; i++) {
		int x, y;	cin >> x >> y;
		int total_sum = 0;
		total_sum += sum[y - 1] - sum[x - 1] + nums[x - 1];
		cout << total_sum << endl;
	}
	
	return 0;
}